<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/9 0009
 * Time: 9:34
 */

namespace app\common\model;

use think\facade\Request;
use think\Model;
use think\model\concern\SoftDelete;

class Record extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';

    /**
     * 查询
     * @param $where
     * @param $field
     * @return Record|\think\Paginator
     */
    public function getList($where, $field)
    {
        return $this
            ->alias('r')
            ->leftJoin(['user'=>'u'],'r.user_id = u.id')
            ->where($where)->field($field)->order('r.id DESC')->paginate(15,false,['query'=>Request::param()]);
    }

    /**
     * 添加
     * @param $data
     * @return bool
     */
    public function addData($data)
    {
        return $this->insertGetId($data);
    }
}
